package com.usian;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = "classpath:applicationContext-redis.xml")
public class Set {
    @Autowired
    private RedisTemplate redisTemplate;
    //存
    @Test
    public void set(){
        redisTemplate.boundSetOps("zhu").add("122");
        redisTemplate.boundSetOps("zhu").add("953");
        redisTemplate.boundSetOps("zhu").add("144");
        redisTemplate.boundSetOps("zhu").add("126");
    }
    //取
    @Test
    public void get(){
        Object name =  redisTemplate.boundSetOps("zhu").members();
        System.out.println(name);
    }
    //单删
    @Test
    public void  delSet(){
        redisTemplate.boundSetOps("zhu").remove("122");
    }
    //全删
    @Test
    public void delete(){
        redisTemplate.delete("zhu");
    }
}
